<?php
/**
* Red RUgolok
* @version $Id: item.class.php
* @package RUgolok
* @subpackage item.class.php
* @author el_leo and manicon
* @copyright (C) el_leo and manicon, www.rugolok.de
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

// Types

function import_text($type, $pieces, $complex) {
	global $my, $database;
	$board = 0;
	switch ($type) {
			case 1: $board=14;
			case 2: $board=15; 
			
	}
	$database->setQuery( "SELECT T.ID_TOPIC as ID_TOPIC, T.ID_FIRST_MSG as ID_FIRST_MSG, T.ID_MEMBER_STARTED as ID_MEMBER_STARTED, T.numReplies as numReplies, T.numViews as numViews, M.subject as subject, M.posterTime as posterTime, M.modifiedTime as modifiedTime, M.body as body, U.username as username, U.id as user_id FROM smf_topics T LEFT JOIN smf_messages M ON (T.ID_FIRST_MSG = M.ID_MSG) LEFT JOIN jos_users U ON (M.posterName = U.username) WHERE T.ID_BOARD=".$board." ORDER BY T.ID_TOPIC ASC");
	if ($members = $database->loadObjectList()) {

		foreach ($members as $member) {
			
			$creative = new Item();
			$creative->type_id = $type;
			$creative->smf_topic_id = $member->ID_TOPIC;
			$creative->checkID = md5(microtime());
			$creative->date = $member->posterTime;
			$creative->last_update = $member->modifiedTime;
			$creative->views = $member->numViews;
			$creative->comments = $member->numReplies;
			$creative->title = $member->subject;
												
			$creative->text = cleanBBcode($member->body, $pieces, $complex);
			$creative->description = $creative->text;
			
			$creative->authors[0] = $member->user_id;
			echo "<b>Creative...</b>".$creative->title."<br>";
//			print_r ($creative) ;
			$creative->insert();
			echo "...inserted.<br>";
			
			$database->setQuery( "SELECT M.ID_TOPIC as item_id, U.id as jos_user_id, M.body as comment_text, M.posterTime as comment_date FROM smf_messages M LEFT JOIN jos_users U ON (M.posterName = U.username) WHERE M.ID_TOPIC=".$creative->smf_topic_id." ORDER BY M.posterTime ASC LIMIT 1,".$creative->comments);
			if ($comments = $database->loadObjectList()) {
					foreach ($comments as $comment) {
							$comment->comment_text = cleanBBcode($comment->comment_text, $pieces, $complex);
							
							$database->setQuery( "SELECT id FROM #__redrugolok_items WHERE smf_topic_id=".$creative->smf_topic_id);
							if ($item_id = $database->loadResult()) {
								$comment->item_id = $item_id;
							}
							else HTML_redrugolok::warning(_RR_COMMENT_ERROR." ".$database->getErrorMsg());
							echo "<b>Comment...</b><br>";
							print_r($comment);
// insert comment
				 			if(!$database->insertObject("#__redrugolok_comments", &$comment))
								HTML_redrugolok::warning(_RR_COMMENT_ERROR." ".$database->getErrorMsg());	
							else echo "...inserted.<br>";
					}
			} else HTML_redrugolok::warning(_RR_COMMENT_ERROR." ".$database->getErrorMsg());
			echo "<br>";	
	



			/*
		    echo $member->ID_TOPIC;
			echo "&nbsp;";
			echo $member->ID_FIRST_MSG;
			echo "&nbsp;";
			echo $member->posterTime;
			echo " / ";
			echo $member->modifiedTime;
			echo "<br>";
			echo "<b>".$member->subject."</b>";
			echo "<br>";
			echo $member->body;
			echo "<br>";
			echo $creative->description;
			echo "<br>";
			echo $member->ID_MEMBER_STARTED;
			echo " / ";
			echo $member->user_id;
			echo "&nbsp;";
			echo "<b>".$member->username."</b>";
			echo "<br>";
			echo "<br>";
			*/
			

		}
	}
	else echo "NIX!";
}

function import_file($type, $pieces, $complex) {
	global $my, $database;
	$board = 0;
	switch ($type) {
			case 3: $board=16;
			case 4: $board=18; 
			
	}
	$database->setQuery( "SELECT T.ID_TOPIC as ID_TOPIC, A.filename as filename, T.ID_FIRST_MSG as ID_FIRST_MSG, T.ID_MEMBER_STARTED as ID_MEMBER_STARTED, T.numReplies as numReplies, T.numViews as numViews, M.subject as subject, M.posterTime as posterTime, M.modifiedTime as modifiedTime, M.body as body, U.username as username, U.id as user_id FROM smf_topics T LEFT JOIN smf_messages M ON (T.ID_FIRST_MSG = M.ID_MSG) LEFT JOIN jos_users U ON (M.posterName = U.username) LEFT JOIN smf_attachments A ON (T.ID_FIRST_MSG = A.ID_MSG) WHERE T.ID_BOARD=".$board." ORDER BY T.ID_TOPIC ASC");
	if ($members = $database->loadObjectList()) {

		foreach ($members as $member) {
		if (!strpos( $member->filename, "_thumb" ))	{
			$creative = new Item();
			$creative->type_id = $type;
			$creative->smf_topic_id = $member->ID_TOPIC;
			$creative->checkID = md5(microtime());
			$creative->date = $member->posterTime;
			$creative->last_update = $member->modifiedTime;
			$creative->views = $member->numViews;
			$creative->comments = $member->numReplies;
			$creative->title = $member->subject;
			
			$creative->description = str_replace($pieces, "", $member->body);
			$takeout = array();
			$index=0;
			foreach ($complex as $compl) {
			$end = 0;
			for ($i=$index; $i< (substr_count ( $creative->description, $compl ) + $index); $i++) {
					$begin = strpos ($creative->description, $compl, $end);
					$end = strpos ($creative->description, "]", $begin);
					$takeout[$i] = substr ($creative->description,$begin, $end-$begin+1);
			}
			$index = $i+1;
			}						 
			$creative->description = str_replace($takeout, "", $creative->description);

			$creative->description = str_replace(_RR_REPLACE_A1, _RR_REPLACE_B1, $creative->description);
			$creative->description = str_replace(_RR_REPLACE_A2, _RR_REPLACE_B2, $creative->description);
			$creative->description = str_replace(_RR_REPLACE_A3, _RR_REPLACE_B3, $creative->description);
			$creative->description = str_replace(_RR_REPLACE_A4, _RR_REPLACE_B4, $creative->description);
			$creative->description = str_replace("[img]", "<img src=\"", $creative->description);
			$creative->description = str_replace("[/img]", "\" border=\"0\" />", $creative->description);			
			$makelink = array();
			$link = array();
			$end = 0;
			for ($i=0; $i< substr_count ( $creative->description, "[url=" ); $i++) {
					$begin = strpos ($creative->description, "[url=", $end);
					$end = strpos ($creative->description, "]", $begin);
					$makelink[$i] = substr ($creative->description, $begin, $end-$begin+1);
					$link[$i] = "<a href=\"".substr ($creative->description, $begin+5, $end-$begin-5)."\">";
			}
			$creative->description = str_replace($makelink, $link, $creative->description);
			$creative->description = str_replace("[/url]", "</a>", $creative->description);			
			
			
			$creative->file = $member->filename;
			$creative->authors = $member->user_id;
			$creative->insert();
			



			
		    echo $member->ID_TOPIC;
			echo "&nbsp;";
			echo $member->ID_FIRST_MSG;
			echo "&nbsp;";
			echo $member->posterTime;
			echo " / ";
			echo $member->modifiedTime;
			echo "<br>";
			echo "<b>".$member->subject."</b>";
			echo "<br>";
			echo $member->body;
			echo "<br>";
			echo $creative->description;
			echo "<br>";
			echo $member->ID_MEMBER_STARTED;
			echo " / ";
			echo $member->user_id;
			echo "&nbsp;";
			echo "<b>".$member->username."</b>";
			echo "<br>";
			echo "<br>";
			
			
		}
		}
	}
	else echo "NIX!";
}


function importRR() {

global $database;

	$pieces = explode("\n", _RR_BLOCK_SMILIESLIST);
	$complex = explode("\n", _RR_BLOCK_COMPLEX);
// TODO [url]...[/url] 
//	import_text(1, $pieces, $complex);
	import_text(2, $pieces, $complex);
//	import_file(3, $pieces, $complex);
//	import_file(4, $pieces, $complex);
	
}

function cleanBBcode($textToClean, $pieces, $complex) {
		global $database;
		
			$textToClean = str_replace($pieces, "", $textToClean);
			$takeout = array();
			$index=0;
			foreach ($complex as $compl) {
			$end = 0;
			for ($i=$index; $i< (substr_count ( $textToClean, $compl ) + $index); $i++) {
					$begin = strpos ($textToClean, $compl, $end);
					$end = strpos ($textToClean, "]", $begin);
					$takeout[$i] = substr ($textToClean, $begin, $end-$begin+1);
			}
			$index = $i+1;
			}						 
			$textToClean = str_replace($takeout, "", $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A1, _RR_REPLACE_B1, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A2, _RR_REPLACE_B2, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A3, _RR_REPLACE_B3, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A4, _RR_REPLACE_B4, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A5, _RR_REPLACE_B5, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A6, _RR_REPLACE_B6, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A7, _RR_REPLACE_B7, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A8, _RR_REPLACE_B8, $textToClean);				
			$textToClean = str_replace(_RR_REPLACE_A9, _RR_REPLACE_B9, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A10, _RR_REPLACE_B10, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A11, _RR_REPLACE_B11, $textToClean);
			$textToClean = str_replace(_RR_REPLACE_A12, _RR_REPLACE_B12, $textToClean);
			
			$textToClean = str_replace("[img]", "<img src=\"", $textToClean);
			$textToClean = str_replace("[/img]", "\" border=\"0\" />", $textToClean);			
			$makelink = array();
			$link = array();
			$end = 0;
			for ($i=0; $i< substr_count ( $textToClean, "[url=" ); $i++) {
					$begin = strpos ($textToClean, "[url=", $end);
					$end = strpos ($textToClean, "]", $begin);
					$makelink[$i] = substr ($textToClean, $begin, $end-$begin+1);
					$link[$i] = "<a href=\"".substr ($textToClean, $begin+5, $end-$begin-5)."\">";
			}
			$textToClean = str_replace($makelink, $link, $textToClean);
			$textToClean = str_replace("[/url]", "</a>", $textToClean);			
			$textToClean = str_replace("[b]", "<b>", $textToClean);
			$textToClean = str_replace("[/b]", "</b>", $textToClean);
			$textToClean = str_replace("[u]", "<u>", $textToClean);
			$textToClean = str_replace("[/u]", "</u>", $textToClean);
			$textToClean = str_replace("[i]", "<i>", $textToClean);
			$textToClean = str_replace("[/i]", "</i>", $textToClean);
//			$textToClean = str_replace("[quote]", "<span class=\"quote\">", $textToClean);
//			$textToClean = str_replace("[/quote]", "</span>", $textToClean);

			
			return $textToClean;		
}

function rate() {
	global $my, $_POST;
		
	if (isset($_POST["action"])) {
		if($_POST["action"] == "rate" ) {
			$author = computeWeight();
			if ($author) {
				echo "<br>Weight: ".$author["weight"];
				echo "<br>Autor: ".$author["author_user_id"];
				$item = saveMark($author);
				if ($item) {
					echo "<br>Mark: ".$item["points"];
				}
			} else echo "Wrong Hashcode!";
		}
	}
}

function smf_member_id($username) {
	global $database;
	$database->setQuery( "SELECT ID_member FROM smf_members WHERE memberName='".$username."'");
	if ($member = $database->loadResult()) {
		return $member;
	}
	else return "error";
}

function get_username($jos_user_id) {
	global $database;
	$database->setQuery( "SELECT username FROM #__users WHERE id='".$jos_user_id."'");
	if ($username = $database->loadResult()) {
		return $username;
	}
	else return "error";
}

function show_username($user_id, $user_name) {
	$link = "<a href=\"?$user_id\" title=\"$user_name\">$user_name";
	$link .= "<img src=\"components/com_rugolokuserlist/images/";
	$link .= (isOnline($user_id))?("icon_useron_s.gif"):("icon_useroff_s.gif");
	$link .= "\" alt=\"Profile\">";
	return $link;
}

function showLinkToAllItems($user_id){
	$link = "<a href=\"?$user_id\">></a>";
	return $link;		
}

function getTypeNameById($type_id){
	global $database;
	$query = "SELECT name FROM #__redrugolok_types WHERE id = ".$type_id."";
	$database->setQuery( $query );
	if ($type_name = $database->loadResult()) {
		return $type_name;
	}
	return null;
}

function showLinkToType($type_id){
	global $Itemid;
	if( $type_name = getTypeNameById($type_id) ){
		$link = "<a href=\"index.php?option=com_redrugolok&Itemid=$Itemid&task=showType&id=$type_id\">$type_name</a>";
		return $link;	
	}
	
	return '';
}

function isOnline($user_id){
	global $database;
	$query = "SELECT session_id FROM #__session WHERE userid = ".$user_id."";
	$database->setQuery( $query );
	if ($session = $database->loadResult()) {
		return 1;
	}
	return 0;
}

function may_rate($item_id, $user_id) {
	global $database;
	$result = "ok";
	if (has_already_rated($item_id, $user_id)) $result="Sie haben dieses Kreativ schon bewertet.";
	else {
		if (is_owner($item_id, $user_id)) $result="Sie sind der Autor dieses Kreativs.";
		else {
			;
		}
	}
	return $result;
}

function has_already_rated($item_id, $user_id) {
	global $database;
	if ($user_id != 0) {
		$database->setQuery( "SELECT count(item_id) as already_rated FROM #__redrugolok_points WHERE item_id='".$item_id."' AND user_id='".$user_id."'");
		$already_rated = $database->loadResult();
		if ($already_rated > 0) {
			return true;
		}
		else return false;
	}
	else return false;
}

function is_owner($item_id, $user_id) {
	global $database;
	$database->setQuery( "SELECT count(item_id) as is_owner FROM #__redrugolok_items_to_authors WHERE item_id='".$item_id."' AND author_id='".$user_id."'");
	$is_owner = $database->loadResult();
	if ($is_owner > 0)  {
		return true;
	}
	else return false;
}

function computeWeight() {
	global $_POST, $database, $my;
/*  first get the systems parameters for each property:
	weight and the point, from which the property has 100% */
	$weights = array();
	
	$weights["share_items"]["weight"] = $_POST["weight_share_items"];
	$weights["share_marks"]["weight"] = $_POST["weight_share_marks"];
	$weights["share_comments"]["weight"] = $_POST["weight_share_comments"];
	$weights["avg_points"]["weight"] = $_POST["weight_avg_points"];
	$weights["points"]["weight"] = $_POST["weight_points"];
	$weights["share_items"]["border"] = $_POST["border_share_items"];
	$weights["share_marks"]["border"] = $_POST["border_share_marks"];
	$weights["share_comments"]["border"] = $_POST["border_share_comments"];
	$weights["avg_points"]["border"] = $_POST["border_avg_points"];
	$weights["points"]["border"] = $_POST["border_points"];
	$weights["fix_part"] = $_POST["fix_part"];
	
	$author = array();

	$author["user_id"] = $my->id;
	if ($author["user_id"] != 0) {
		$author["username"] = $my->username;
		$author["smf_member_id"] = smf_member_id($my->username);	
	} else {
		$author["username"] = $_POST["guestname"];
		$author["smf_member_id"] = 0;
		if ($_POST["hash"] != "Hashcode") {
				return false;
				break; 
		}
	}

	$item = new Item($_POST["item_id"]);
	echo $_POST["item_id"]."AA";
	$author["item_id"] = $_POST["item_id"];
	
	$database->setQuery( "SELECT type_id FROM #__redrugolok_items WHERE id=".$author["item_id"]);	
	$author["category_id"]  = $database->loadResult();
	$database->setQuery( "SELECT author_id FROM #__redrugolok_items_to_authors WHERE item_id=".$author["item_id"]);	
	$author["author_user_id"]  = $database->loadResult();
	$author["mark"] = $_POST["mark"];
	
	$author["author_points"]  = 0;
	$author["author_num_items"] = 0;
	$database->setQuery( "SELECT num_rated_items, points FROM #__redrugolok_authors WHERE jos_user_id=".$author["author_user_id"]." AND category_id=".$author["category_id"]);
	if (($database->loadObject($row)) && ($database->getNumRows()!=0)) {
		$author["author_points"]  = $row->points;
		$author["author_num_items"]  = $row->num_rated_items;
	}
	
	$author["row_id"] = -1;
	$author["num_items"] = 0;
	$author["num_marks"] = 0;
	$author["num_comments"] = 0;
	$author["points"] = 0;
//	$author["sum_items"] = 0;
//	$author["sum_marks"] = 0;
//	$author["sum_comments"] = 0;
//	$author["sum_points"] = 0;

	$database->setQuery( "SELECT DISTINCT id, num_items, num_rated_items, num_marks, num_comments, points FROM #__redrugolok_authors WHERE jos_user_id=".$my->id." AND category_id=".$author["category_id"]);
	if ($database->loadObject($row)) {
		$author["row_id"] = $row->id;
		$author["num_items"] = $row->num_items;
		$author["num_rated_items"] = $row->num_rated_items;
		$author["num_marks"] = $row->num_marks;
		$author["num_comments"] = $row->num_comments;
		$author["points"] = $row->points;
	}
	
	$database->setQuery( "SELECT SUM(num_items) as sum_items, SUM(num_marks) as sum_marks, SUM(num_comments) as sum_comments, SUM(points) as sum_points, COUNT(num_items) as count_items, COUNT(num_marks) as count_marks, COUNT(num_comments) as count_comments, COUNT(points) as count_points FROM #__redrugolok_authors WHERE jos_user_id=".$my->id);
	if ($database->loadObject($row2)) {
		$author["sum_items"] = ( $row2->count_items > 0 ? $row2->sum_items : 0 );
		$author["sum_marks"] = ( $row2->count_marks > 0 ? $row2->sum_marks : 0 );
		$author["sum_comments"] = ( $row2->count_comments > 0 ? $row2->sum_comments : 0 );
		$author["sum_points"] = ( $row2->count_points > 0 ? $row2->sum_points : 0 );
	}

	$author["share_items"] = 0;
	$author["share_marks"] = 0;
	$author["share_comments"] = 0;
				
	$database->setQuery( "SELECT SUM(num_items) as sum_items FROM #__redrugolok_authors");	
	$sum_items = $database->loadResult();
	if ($sum_items != 0) {
		$author["share_items"] = $author["sum_items"] / $sum_items;
		$author["share_marks"] = $author["sum_marks"] / $sum_items;
		$author["share_comments"] = $author["sum_comments"] / $sum_items;		
	}

	$author["avg_points"] = 0;	

	$database->setQuery( "SELECT COUNT(points) as active_categories FROM #__redrugolok_authors WHERE jos_user_id=".$my->id." AND num_rated_items > 0 ");	
	$active_categories = $database->loadResult();
	if ($active_categories != 0) {
		$author["avg_points"] = $author["sum_points"] / $active_categories;	
	}
	
	// now count the power for each property of this user
	
	$author["rating"]["items"] = ( $author["share_items"] / $weights["share_items"]["border"] > 1 ? 1 : $author["share_items"] / $weights["share_items"]["border"] );
	$author["rating"]["marks"] = ( $author["share_marks"] / $weights["share_marks"]["border"] > 1 ? 1 : $author["share_marks"] / $weights["share_marks"]["border"] );
	$author["rating"]["comments"] = ( $author["share_comments"] / $weights["share_comments"]["border"] > 1 ? 1 : $author["share_comments"] / $weights["share_comments"]["border"] );
	$author["rating"]["avg_points"] = ( $author["avg_points"] / $weights["avg_points"]["border"] > 1 ? 1 : $author["avg_points"] / $weights["avg_points"]["border"] );
	$author["rating"]["points"] = ( $author["points"] / $weights["points"]["border"] > 1 ? 1 : $author["points"] / $weights["points"]["border"] );
	
	$author["weight"] = $weights["fix_part"] + (1 - $weights["fix_part"])*($author["rating"]["items"]*$weights["share_items"]["weight"] + $author["rating"]["marks"]*$weights["share_marks"]["weight"] + $author["rating"]["comments"]*$weights["share_comments"]["weight"] + $author["rating"]["avg_points"]*$weights["avg_points"]["weight"] + $author["rating"]["points"]*$weights["points"]["weight"]);
	
	print_r($author);
	
	return $author;
}

function saveMark($author) {
	global $_POST, $database;

	// first get the information about the item
	$item = array();
		
	$database->setQuery( "SELECT DISTINCT num_marks, points, avg_weight FROM #__redrugolok_items WHERE id=".$author["item_id"]);
	if ($database->loadObject($row)) {
		$item["num_marks"] = $row->num_marks;
		$item["points"] = $row->points;
		$item["avg_weight"] = $row->avg_weight;
	}	else {
		return false;
		break;
	}
	
/*  now compute the avg mark as if there were no weights
	the formula is avg = ( num_marks*points + new_mark ) / (num_marks + 1) */
	$avg_mark = ( $item["num_marks"] * $item["points"] + $author["mark"] ) / ( $item["num_marks"] + 1 );
	echo "<br> AVG MARK: ".$avg_mark;
/*  then take the weight into account
	the formula is fin = points + ( avg - points )* (user_weight + positive_weight_difference) */
	$weight_diff = ( $author["weight"] > $item["avg_weight"] ? $author["weight"] - $item["avg_weight"] : 0 );
	echo "<br> WEIGHT DIFF: ".$weight_diff;	
	$avg_mark = $item["points"] + ( $avg_mark - $item["points"] ) * ( $author["weight"] + $weight_diff );
	//now update item
	echo "<br>WEIGHTED AVG MARK: ".$avg_mark;
	$item["avg_weight"] = ( $item["num_marks"] * $item["avg_weight"] + $author["weight"] ) / ( $item["num_marks"] + 1 );
	$item["points"] = $avg_mark;
	$item["num_marks"]++;
	
	if ( (!has_already_rated($author["item_id"], $author["user_id"])) || ($author["user_id"]==0) ) {

		// update item
		//TODO (Auch last_rater anlegen?)
		$database->setQuery( "UPDATE #__redrugolok_items SET points = ".$item["points"].", num_marks = num_marks +1, avg_weight = ".$item["avg_weight"]." where id=".$author["item_id"]);
		if (!$database->query()) {
			echo "<script> alert('".$database->stderr()."');</script>\n";
			exit();
		}
		//insert points
		$query = "INSERT INTO #__redrugolok_points (date, item_id, user_id, points, weight, show_me) VALUES ('".time()."', '".$author["item_id"]."', '".$author["user_id"]."', '".$author["mark"]."', '".$author["weight"]."', 1)";
		echo $query;	
		$database->setQuery( $query );
		if (!$database->query()) {
			echo "<script> alert('".$database->stderr()."');</script>\n";
			exit();
		}
		//update rater
		if ($author["user_id"]!=0)	 {
			$query = "UPDATE #__redrugolok_authors SET num_marks = num_marks + 1 where jos_user_id=".$author["user_id"]." and category_id=".$author["category_id"];
			echo $query;	
			$database->setQuery( $query );
			if (!$database->query()) {
				echo "<script> alert('".$database->stderr()."');</script>\n";
				exit();
			}
		}
		//update author
		//new_avg_points for this category
		
		$new_avg_points = ($author["author_num_items"]*$author["author_user_id"] + $item["points"])/($author["num_rated_items"] + 1);
		$query = "UPDATE #__redrugolok_authors SET points = ".$new_avg_points." where jos_user_id=".$author["author_user_id"]." and category_id=".$author["category_id"];
		echo $query;	
		$database->setQuery( $query );
		if (!$database->query()) {
			echo "<script> alert('".$database->stderr()."');</script>\n";
			exit();
		}
					
	}

	return $item;	
	 
}

function getCommentsByItemId($item_id){
	global $database;
	
	$query = "SELECT * FROM #__redrugolok_comments WHERE item_id = $item_id ORDER BY id DESC";
	$database->setQuery( $query );
	if ($comments = $database->loadObjectList()) {
		return $comments;
	}
	return 0;
}


?>
